package com.kun.reflection.demo02_memoryAnalysis;


//不同的类加载器
public class Test03_classLoaders {


    public static void main(String[] args) throws ClassNotFoundException {
        //1. 系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println("系统类加载器：" + systemClassLoader);

        //2. 扩展类加载器
        ClassLoader extClassLoader = systemClassLoader.getParent();
        System.out.println("扩展类加载器：" + extClassLoader);

        //3. 根加载器/引导类加载器，无法获取，由C++实现
        ClassLoader appClassLoader = extClassLoader.getParent();
        System.out.println("根加载器/引导类加载器：" + appClassLoader);

        //测试JDK内置的类由谁加载---根加载器
        ClassLoader classLoader = Class.forName("java.lang.Object").getClassLoader();
        System.out.println("java.lang.Object由：" + classLoader+"加载");

        //测试当前类由谁加载---系统类加载器
        ClassLoader classLoader1 = Test03_classLoaders.class.getClassLoader();
        System.out.println("Test03_classLoaders类由：" + classLoader1+"加载");

        //测试系统类加载器可以加载的路径
        System.out.println("系统类加载器可以加载的路径：" + System.getProperty("java.class.path"));

        /**
         * D:\jdk8\jre\lib\cat.jar;
         * D:\jdk8\jre\lib\charsets.jar;
         * D:\jdk8\jre\lib\ext\access-bridge-64.jar;
         * D:\jdk8\jre\lib\ext\cldrdata.jar;
         * D:\jdk8\jre\lib\ext\crs-agent.jar;
         * D:\jdk8\jre\lib\ext\dnsns.jar;
         * D:\jdk8\jre\lib\ext\jaccess.jar;
         * D:\jdk8\jre\lib\ext\localedata.jar;
         * D:\jdk8\jre\lib\ext\nashorn.jar;
         * D:\jdk8\jre\lib\ext\sunec.jar;
         * D:\jdk8\jre\lib\ext\sunjce_provider.jar;
         * D:\jdk8\jre\lib\ext\sunmscapi.jar;
         * D:\jdk8\jre\lib\ext\sunpkcs11.jar;
         * D:\jdk8\jre\lib\ext\zipfs.jar;
         * D:\jdk8\jre\lib\jce.jar;D:\jdk8\jre\lib\jfr.jar;
         * D:\jdk8\jre\lib\jsse.jar;D:\jdk8\jre\lib\management-agent.jar;
         * D:\jdk8\jre\lib\resources.jar;
         * D:\jdk8\jre\lib\rt.jar;
         * C:\Users\23127\Desktop\temp\code\AnnotationAndReflectionStudy\target\classes;
         * F:\maven-data\maven-repository\junit\junit\4.13.2\junit-4.13.2.jar;
         * F:\maven-data\maven-repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;
         * F:\maven-data\maven-repository\org\projectlombok\lombok\1.18.34\lombok-1.18.34.jar;
         * D:\idea\IntelliJ IDEA 2023.2\lib\idea_rt.jar
         */

    }

}
